<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <input type="text" placeholder="请输入数量" />
  <input type="button" value="帅哥" onclick="f(1)"/>
  <input type="button" value="美女" onclick="f(0)"/>
</div>
</body>
<script>
  let i1 = document.querySelector("input");

  function f(type){
    for(let i=1;i<=i1.value;i++){
      //创建图片标签
      let img = document.createElement("img");
      img.width = 100;
      img.height = 100;
      /*switch (type){
        case 0:
          img.src="../b.jpg";break;
        case 1:
          img.src="../a.jpg";break;
      }*/
      //设置图片的显示内容
      img.src = type==0?"../b.jpg" : "../a.jpg";
      //添加图片标签到body里面
      document.body.append(img);
    }

  }

</script>
</html>